import { connect } from 'redux'
import todoList from '../TodoList'
import { toggleState } from '../action'

const getVisibleList = (lists, filter) => {
    switch (filter) {
        case 'all':
            return lists
        case 'completed':
            return lists.filter(list => list.completed)
        case 'active':
            return lists.filter(list => !list.completed)
        default: 
            return lists
    }
}

const mapStateToProps = (state) => ({
    lists: state.lists
})

const mapDispatchToProps = (dispatch) => ({
    toggleList: id => dispatch(toggleState(id))
})

export default connect(mapStateToProps, mapDispatchToProps)(todoList)